{include file="index/head" /}
<script src="/public/ueditor/ueditor.config.js"></script>
<script src="/public/ueditor/ueditor.all.js"></script>

<div class="box" id="app">
  <form method="post" action="{:url('add')}" class="sycmsform">
    <div class="box-head">
      <ul class="bhtab">
        <li class="on"><a href="javascript:void(0);"><i class="icon-comment"></i> 基本信息</a></li>
        <li><a href="javascript:void(0);"><i class="icon-paper-plane"></i> 其他信息</a></li>
      </ul>
      <div class="fr">
        <button type="submit" class="btn"><i class="icon-check"></i>{$v.id?'编辑':'添加'}</button>
        &nbsp;<a href="javascript:history.go(-1);" class="btn fr"><i class="icon-mail-reply (alias)"></i>返回</a></div>
    </div>
    <div class="form">
    <input type="hidden" name="id" value="{$v.id}" />
    <input type="hidden" name="nid" value="{$nid}" />
    <input type="hidden" name="mid" value="{$mid}" />
    <ul class="tabcon" style="display:block;">
      <li>
        <label>标题：</label>
        <div class="item">
          <input type="text" name="title" value="{$v.title}" class="input w60" datatype="*" nullmsg="请输入标题"/>
        </div>
      </li>
      <li>
        <label>副标题：</label>
        <div class="item">
          <input type="text" class="input" name="subtitle" value="{$v.subtitle}" />
        </div>
      </li>
      <!-- 案例 -->     
      <li>
        <label>外部连接：</label>
        <div class="item">
          <input type="text" name="url" value="{$v.url}" class="input"/>
          <div class="clear"></div>          
        </div>
      </li> 
					 {if condition="$mid eq 3"} 
						<li>
						  <label>产品价格：</label>
						  <div class="item">
						    <input type="text" name="price" value="{$v.price}" class="input"/>
						    <div class="clear"></div>          
						  </div>
						</li> 
					 {/if}
    
      {if condition="$iscid eq 1"}
      <li>
        <label>所属分类：</label>
        <div class="item">
          <div class="select"><i class="icon-caret-down"></i>
            <input type="hidden" name="cid" value="{$v.cid}" class="inputval"  />
            <input type="text" readonly placeholder="请选择分类" value="" class="input" datatype="*" nullmsg="请选择分类"/>
            <dl class="select-value syui-anim syui-anim-up">
              {volist name="list" id="vo"}                         
              <dd data="{$vo.id}" {if condition="$vo.id eq $v.cid"}class=selected{/if}>{$vo.title}</dd>                           
              {volist name="vo['son']" id="vs"}
              <dd data="{$vs.id}" {if condition="$vs.id eq $v.cid"}class=selected{/if}>&nbsp;&nbsp;&nbsp;|--{$vs.title}</dd>
              {volist name="vs['son']" id="vc"}
              <dd data="{$vc.id}" {if condition="$vc.id eq $v.cid"}class=selected{/if}>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|----{$vc.title}</dd>              
              {/volist}              
              {/volist}
              {/volist}
            </dl>
          </div>
        </div>
      </li> 
      {/if}      
      <li>
        <label>属性：</label>
        <div class="item radio">
          <span><input type="checkbox" onclick="_checkbox('ishome')" {if condition="$v.ishome eq 1"} checked="checked" {/if} /> 首页</span>
          <span><input type="checkbox" onclick="_checkbox('isvouch')" {if condition="$v.isvouch eq 1"} checked="checked" {/if}/> 推荐</span>
          <span><input type="checkbox" onclick="_checkbox('istop')" {if condition="$v.istop eq 1"} checked="checked" {/if}/> 置顶</span>
          <input type="hidden" name="ishome" value="{$v.ishome|default=0}"  />
          <input type="hidden" name="isvouch" value="{$v.isvouch|default=0}" />
          <input type="hidden" name="istop" value="{$v.istop|default=0}"  />
        </div>
      </li>
      <li>
        <label>列表图片：</label>
        <div class="item">
          <input type="text" name="img" value="{$v.img}" class="input"/>
          <button type="button" class="button fl" onclick="sycms.showupload(this)" id="image1" at="dg"><i class="icon-plus"></i>上传图片</button>
          <span class="tips">{$v.imgtips}</span>
          <div class="clear"></div>
          <div class="input-image">{if $v.img}<img src="{$v.img}" alt="" />{/if}</div>
        </div>
      </li>
      <!-- 产品模块 -->
      {if condition="$mid eq 3"}    
			 <li>
				 <label>多图：</label>
				 <div class="item">
					 <dl class="uploadListImg">          
					 <dd v-for="(item,index) in imgList" :key="index" v-if="imgList.length>0">
						<em class="icon-angle-left" v-if="index!=0" @click="move(index,1)"></em>
						<em class="icon-angle-right" v-if="index!=imgList.length-1" @click="move(index,2)"></em>
						<a :href="item" class="imgview"><img :src="item" /></a>
						<input type="hidden" name="imgs[]" :value="item" />
						<span @click="imgList.splice(index,1)">x</span>
					</dd>          
					 <dd><a href="javascript:void(0);" onclick="sycms.showupload(this)" id="image2" class="upimgadd" at="pl"></a></dd>
					 </dl>       
				 </div>
			 </li>
      {/if}        
      <!-- 下载模块 -->
      {if condition="$mid eq 4"}
      <li>
        <label>下载地址：</label>
        <div class="item">
          <input type="text" name="file" value="{$v.file}" class="input"/>
          <button type="button" class="button fl" onclick="sycms.showupfile(this)" id="uploadfile" at="file"><i class="icon-plus"></i>上传文件</button>
          <div class="clear"></div>          
        </div>
      </li>      
      {/if}      
       <!-- 视频模块 -->
      {if condition="$mid eq 5"}
      <li>
        <label>视频地址：</label>
        <div class="item">
          <input type="text" name="url" value="{$v.url}" class="input"/>
          <button type="button" class="button fl" onclick="sycms.showupfile(this)" id="uploadfile2" at="video"><i class="icon-plus"></i>上传视频</button>
          <div class="clear"></div>          
        </div>
      </li>      
      {/if}      
      <li style="margin-bottom:15px; overflow:hidden;">
        <label>描述：</label>
        <div class="item">
          <textarea type="text" class="input w100" name="note"  style="height:80px;">{$v.note}</textarea>
        </div>
      </li>      
      <li style="margin-bottom:15px; overflow:hidden;">
        <label>内容：</label>
        <div class="item">            
          <script id="content" name="content" type="text/plain" style="width:100%;height:500px;">{$v.content}</script>   
          <script> var ue = UE.getEditor("content"); ue.ready(function() { ue.setHeight(500); });</script>    
        </div>
      </li>       
      {if condition="$mid eq 3"} 
      <li style="margin-bottom:15px; overflow:hidden;">
        <label>产品参数：</label>
        <div class="item">
         <script id="content1" name="content1" type="text/plain" style="width:100%;height:500px;">{$v.content1}</script>  
         <script> var ue2 = UE.getEditor("content1"); ue2.ready(function() { ue2.setHeight(500); });</script>         
        </div>
      </li> 
      {/if}  
     
    </ul>
    <!-- 其他信息 -->
    <ul class="tabcon">
      <li>
        <label>SEO标题：</label>
        <div class="item">
          <input type="text" class="input w100" value="{$v.seo_title}" name="seo_title"  />
        </div>
      </li>
      <li>
        <label>SEO关键字：</label>
        <div class="item">
          <input type="text" class="input w100" value="{$v.seo_keywords}" name="seo_keywords"  />
        </div>
      </li>
      <li>
        <label>SEO描述：</label>
        <div class="item">
          <textarea type="text" class="input w100" name="seo_description">{$v.seo_description}</textarea>
        </div>
      </li>
      <li style="margin-top:15px;">
        <label>排序：</label>
        <div class="item">
          <input type="text" class="input" type="number" value="{$v.sort|default=0}" name="sort"  />
        </div>
      </li>
      <li>
        <label>作者：</label>
        <div class="item">
          <input type="text" class="input" type="text" value="{$v.author|default='admin'}" name="author"  />
        </div>
      </li>
      <li>
        <label>来源：</label>
        <div class="item">
          <input type="text" class="input" type="text" value="{$v.source|default='本站'}" name="source"  />
        </div>
      </li>
      <li>
        <label>发布时间：</label>
        <div class="item">
          <input type="text" class="input icon-date" type="text" id="datetime" value="{if $v.datetime}{$v.datetime|date='Y-m-d H:i:s',###}{/if}" name="datetime"  />
        </div>
      </li>
    </ul>    
    <ul>
      <li>
        <label>&nbsp;</label>
        <div class="item">
          <button type="submit" class="button"><i class="icon-check"></i>{$v.id?'编辑':'添加'}</button>
        </div>
      </li>
    </ul>
  </form>
</div>
</div>

<script src="https://lib.baomitu.com/vue/2.6.11/vue.min.js"></script>
<script>
 var vues = new Vue({
    el: '#app',
    data: {
			title:"adsf",
			imgList:[]
		},
		mounted(){
			if('{$imgList}'!=""){
				this.imgList = JSON.parse('{$imgList}');
			}
		},
		methods:{
			move(index,type){
				if(type==2){ //上移
					let arr = this.imgList;
					arr.splice(index, 1, ...arr.splice(index + 1, 1, arr[index]));
				}else{ //下移
					let arr = this.imgList;
					arr.splice(index - 1, 1, ...arr.splice(index, 1, arr[index - 1]));
				}
			}
		}
})
</script>

<script> 
sycms.submitform("{:url('index',['nid'=>$nid])}"); 
layui.use('laydate', function(){
  var laydate = layui.laydate;
  laydate.render({
    elem: '#datetime' //指定元素
	,type: 'datetime'
	,isInitValue:false
  });
});
function _checkbox(name){
   var v = $("input[name="+name+"]").val();
       v = v==0?1:0;
   $("input[name="+name+"]").val(v);	
}
$(function(){
	$(".box-head ul li").click(function(){
		$(this).addClass("on").siblings().removeClass("on");
		$(".tabcon").hide().eq($(this).index()).show();
	})	
})
</script>